//
//  TaxInfoViewController.m
//  Hxcsfw
//
//  Created by qiysoft on 2017/10/27.
//  Copyright © 2017年 企友软mac. All rights reserved.
//

#import "TaxInfoViewController.h"
#import "TaxInfoCell.h"
#import "ZXCell.h"
#import "RegulationCell.h"
#import "SpokenViewController.h"
#import "WWebViewController.h"
#import "TaxInfoDetailViewController.h"
#import "TaxInfoModel.h"
#import "HHBaseLoadToken.h"
#import "FGModel.h"
#import "TextDetailViewController.h"
#import "UIImageView+WebCache.h"
#import "TaxInfoHead.h"

#define TaxInfoCellIndentifier @"TaxInfoCellIndentifier"

@interface TaxInfoViewController ()<UITableViewDelegate,UITableViewDataSource,TaxInfoCellDelegate,TermCellDelegate,TaxInfoHeadDelegate>{
    UIView *bgView;
    int j;
    int k;
    BOOL isRegulations;
    BOOL isDate;
    BOOL isCate;
    NSString *strDate;
    NSString *strCate;
    CGFloat cellTitH;
    CGFloat offsetH;
}

@property (nonatomic,strong)NSMutableArray *arrTaxInfo;
@property (nonatomic,strong)UITableView *tableRight;
@property (nonatomic,strong)UITableView *tableLeft;
@property (nonatomic,strong)UITableView *tableDate;

@property (nonatomic, strong) NSMutableArray *arrMfG;// 总数据数组
@property (nonatomic ,strong) NSMutableArray *FGFLArrM;// 法规分类数组
@property (nonatomic ,strong) NSMutableArray *FGFLIDArrM;// 法规分类id数组

@property (nonatomic ,strong) NSMutableArray *FGSZArrM1;
@property (nonatomic ,strong) NSMutableArray *FGSZIDArrM;// 税种id数组
@property (nonatomic, strong) NSArray *RQArrM; //(下拉菜单)日期
@property (nonatomic, strong) NSMutableArray *arrRight;
@property (nonatomic, strong) NSMutableArray *FGSZArrM;// 税种数组

@property (nonatomic ,strong) NSString *cid;// 参数（FGFLID）
@property (nonatomic ,strong) NSString *szid;// 参数（FGSZID）
@property (nonatomic ,strong) NSString *rq;// 参数（日期）

@property (nonatomic ,strong) NSString *COVER;//月刊图片
@property (nonatomic ,strong) NSString *LINK;//月刊地址
@property (nonatomic ,strong) NSString *TITLE;//月刊标题
@property (nonatomic ,strong) NSString *VIEW;//微解读浏览数
@property (nonatomic ,strong) TaxInfoHead *taxHeadView;
@end

@implementation TaxInfoViewController


- (void)viewDidLoad {
    [super viewDidLoad];

    self.arrTaxInfo = [NSMutableArray array];
    k = 1;
    j = 1;
    _cid = @"";
    _szid = @"";
    _rq = @"0";
    _FGFLArrM = [NSMutableArray array];
    _FGFLIDArrM = [NSMutableArray array];
    _FGSZArrM = [NSMutableArray array];
    _FGSZArrM1 = [NSMutableArray array];

    _FGSZIDArrM = [NSMutableArray array];
    _arrMfG = [NSMutableArray array];
    _arrRight = [NSMutableArray array];
    _COVER = [NSString string];
    _LINK = [NSString string];
    _TITLE = [NSString string];
    _VIEW = [NSString string];

    // 日期
    self.RQArrM = @[@"全部日期",@"近一个月",@"一到三年",@"三到五年",@"五年以前"];
//    self.arrAll = @[@{@"left":@[@"right",@"right"]},@{@"left1":@[@"right1",@"right1"]}];
//    self.arrRight = self.arrAll[0][[self.arrAll[0] allKeys][0]];

    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"税信";
    
    // 1.注册控件
    UINib *cellNib = [UINib nibWithNibName:@"TaxInfoCell" bundle:nil];
    [self.myTableView registerNib:cellNib forCellReuseIdentifier:TaxInfoCellIndentifier];
    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:TaxInfoCellIndentifier];

    [self requestListDataStrNum:@"1" sort:@"new" isRefrsh:YES];
    [self notifyRequestListData:@"new"];
//    [self.myTableView.header beginRefreshing];
    //政策微解读浏览数
    [self ZCWJDDataRequest];
}
#pragma mark - 政策微解读浏览数
- (void)ZCWJDDataRequest {
    /*
    mode:native,service:sxfw,content:{revert:init}
     */
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"sxfw",@"content":@{@"revert":@"init"}};
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        _COVER = [returnDic objectForKey:@"sxyk"][@"cover"];
        _LINK = [returnDic objectForKey:@"sxyk"][@"link"];
        _TITLE = [returnDic objectForKey:@"sxyk"][@"title"];
        _VIEW = [returnDic objectForKey:@"zcwjd"][@"view"];
        [self.myTableView reloadData];

    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:NO];
}

- (void)viewWillAppear:(BOOL)animated {
    [self.myTableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.myTableView removeObserver:self forKeyPath:@"contentOffset" context:nil];

}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{

    if ([keyPath isEqualToString:@"contentOffset"])

    {
        CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue];
        offsetH = 0;
        offsetH = offset.y;
    }
}

- (void)notifyRequestListData:(NSString *)sort{

    [self.FGFLArrM removeAllObjects];
    [self.FGFLIDArrM removeAllObjects];
    [self.FGSZArrM removeAllObjects];
    [self.FGSZArrM1 removeAllObjects];
    [self.FGSZIDArrM removeAllObjects]; // 清空数组，避免多次添加

    [self loadQueryFgFlList];// 法规分类
    [self loadqueryFgSzList];// 法规税种

    self.myTableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        
        if (isRegulations) {//众可信法规cell
            
            [self requestListDataStrNum:@"1" isRefresh:YES];
            k = 1;
            
        }else{
            [self requestListDataStrNum:@"1" sort:sort isRefrsh:YES];
            j = 1;
        }
    }];

    self.myTableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        
        if (isRegulations) {//众可信法规cell
            
            NSString *num = [NSString stringWithFormat:@"%d",++k];
            [self requestListDataStrNum:num isRefresh:NO];
            
        }else{
            NSString *num = [NSString stringWithFormat:@"%d",++j];
            [self requestListDataStrNum:num sort:sort isRefrsh:NO];
        }
    }];
}

//设置UITableViewCell的数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    if (tableView == self.myTableView){
        if (indexPath.section == 0) {
            TaxInfoCell *taxInfoCell = [[[NSBundle mainBundle] loadNibNamed:@"TaxInfoCell" owner:self options:nil] lastObject];

            if (cell == nil) {
                
                //赋值
                taxInfoCell.LbView.text = [NSString stringWithFormat:@"%@",_VIEW];
//                [taxInfoCell.imgMonthly sd_setImageWithURL:[NSURL URLWithString:_COVER] placeholderImage:[UIImage imageNamed:@"school_image.png"]];
                GifView *gifView = [WShareUtil animatedGifWithData:taxInfoCell.imgMonthly];
                [taxInfoCell.imgMonthly addSubview:gifView];

                [taxInfoCell.imgMonthly sd_setImageWithURL:[NSURL URLWithString:_COVER] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
                    [gifView removeFromSuperview];
                }];

                taxInfoCell.lbMonthly.text = _TITLE;
                
                taxInfoCell.delegate = self;
                taxInfoCell.selectionStyle = UITableViewCellSelectionStyleNone;

                cell = taxInfoCell;
            }

        }else if (indexPath.section == 1) {
            
            if (isRegulations) {//众可信法规cell
                RegulationCell *cell1 = [[[NSBundle mainBundle] loadNibNamed:@"RegulationCell" owner:self options:nil] lastObject];
                if (cell == nil) {
                    if (self.arrMfG.count > 0 && self.arrMfG != nil) {
                        //[[self.arrMfG[indexPath.row]jdid] isKindOfClass:[NSString class]]
                        
                        if ([self.arrMfG[indexPath.row]jdid] == nil || [self.arrMfG[indexPath.row]jdid] == NULL){
                            cell1.understandBtn.hidden = YES;
                            
                        }else {
                            [cell1.understandBtn setImage:[UIImage imageNamed:@"regulation_jiedu.png"] forState:UIControlStateNormal]; cell1.understandBtn.hidden = NO;
                            cell1.delegate = self;
                            cell1.understandBtn.tag = indexPath.row;
                        }
                        
                        //标题1去空格2转义
                        //系统去首尾空格方法，使用NSString中的str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]方法只是去掉左右两边的空格
                        NSString *QKGString = [[self.arrMfG[indexPath.row] strTitle] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];//(去空格)
                        NSString *ZYString1 = [QKGString stringByReplacingOccurrencesOfString:@"&lt;" withString:@"<"];
                        NSString *ZYString2 = [ZYString1 stringByReplacingOccurrencesOfString:@"&gt;" withString:@">"];
                        
                        cell1.lbTitCell.text = ZYString2;//转义后标题
                        cell1.lbTitCell.numberOfLines = 0;
                        cell1.lbTitCell.textAlignment = NSTextAlignmentLeft;
                        cell1.lbTitCell.textColor = [UIColor blackColor];
                        cell1.lbTitCell.font = [UIFont systemFontOfSize:14];
                        CGSize maximumLbTitle = CGSizeMake(WSCREENH_WIDTH - 26, MAXFLOAT);//labelsize的最大值
                        CGSize expectSize = [cell1.lbTitCell sizeThatFits:maximumLbTitle];
                        if (expectSize.height >= 20) {//38.33  19.33
                            expectSize.height = 41.33;
                        }
                        
                        cell1.cellTitH.constant = expectSize.height;
                        cellTitH = expectSize.height;
                        
                        // ---------- 设置titleLB的行间距
                        NSMutableParagraphStyle  *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
                        [paragraphStyle  setLineSpacing:2];
                        
                        if ([WShareUtil strNilOrEmpty:cell1.lbTitCell.text]) {
                            cell1.lbTitCell.text = @"";
                        }
                        NSMutableAttributedString  *setString = [[NSMutableAttributedString alloc] initWithString:cell1.lbTitCell.text];
                        
                        [setString  addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [cell1.lbTitCell.text length])];
                        [cell1.lbTitCell  setAttributedText:setString];// 设置Label要显示的text
                        // ----------
                        
                        cell1.lbTimeCell.text = [self.arrMfG[indexPath.row] createtime];//时间
                        cell1.lbNumCell.text = [self.arrMfG[indexPath.row] strInfo];//字号
                        cell1.fwzhLbCell.text = @"发文字号:";
                        cell1.bbrqLbCell.text = @"颁布日期:";
                    }
                }
                cell = cell1;
                
            }else{
                ZXCell *zxCell = [[[NSBundle mainBundle] loadNibNamed:@"ZXCell" owner:self options:nil] lastObject];
                if (cell == nil) {
                    zxCell.lbTitle.text = [self.arrTaxInfo[indexPath.row] strTitle];
                    zxCell.lbNum.text = [NSString stringWithFormat:@"%@人听过",[self.arrTaxInfo[indexPath.row] llcs]];
                    
                    CGSize maximumLbTitle = CGSizeMake(MAXFLOAT, 20);//labelsize的最大值
                    CGSize expectSize = [zxCell.lbNum sizeThatFits:maximumLbTitle];
                    zxCell.ViewWidth.constant = expectSize.width;
                    
                    zxCell.lbTime.text = [self.arrTaxInfo[indexPath.row] fbsj];
                }
                cell = zxCell;
            }
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

    } else if (tableView == self.tableLeft) {
        if (cell == nil) {

            cell = [[UITableViewCell alloc]init];
            UILabel *lbTit = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WSCREENH_WIDTH * 0.5, 40)];
            lbTit.text = self.FGFLArrM[indexPath.row];
            lbTit.font = [UIFont systemFontOfSize:14];

            lbTit.textAlignment = NSTextAlignmentCenter;
            [cell addSubview:lbTit];
        }
    } else if (tableView == self.tableRight) {
        if (cell == nil) {
            cell = [[UITableViewCell alloc]init];
            UILabel *lbTit = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WSCREENH_WIDTH * 0.5, 40)];
            lbTit.text = self.arrRight[indexPath.row];
            lbTit.font = [UIFont systemFontOfSize:14];

            lbTit.textAlignment = NSTextAlignmentCenter;
            [cell addSubview:lbTit];
        }
    } else if (tableView == self.tableDate) {
        if (cell == nil) {
            cell = [[UITableViewCell alloc]init];
            UILabel *lbTit = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WSCREENH_WIDTH, 40)];
            lbTit.text = self.RQArrM[indexPath.row];
            lbTit.font = [UIFont systemFontOfSize:14];

            lbTit.textAlignment = NSTextAlignmentCenter;
            [cell addSubview:lbTit];
        }
    }

    return cell;

}

//行点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    if (tableView == self.tableLeft) {

        self.tableRight.hidden = NO;

//        self.arrRight = self.arrAll[indexPath.row][[self.arrAll[indexPath.row] allKeys][0]];
        self.arrRight = self.FGSZArrM[indexPath.row];
        NSInteger i = 0;
        if (self.arrRight.count == 0) {
            isCate = YES;
            strCate = self.FGFLArrM[indexPath.row];
            [bgView removeFromSuperview];
            
            //财经法规请求写这
            WLog(@"%@",_FGFLArrM);
            WLog(@"%@",_FGFLIDArrM);
            _cid = [_FGFLIDArrM objectAtIndex:indexPath.row];// 取法规分类的id
            _szid = @"";// 取法规税种的id
            [self requestListDataStrNum:@"1" isRefresh:YES];

            
            [self.myTableView reloadData];
            [self.tableRight removeFromSuperview];
            [self.tableLeft removeFromSuperview];
            return;
        } else {
            if (self.arrRight.count > 6) {
                i = 6;
            }else {
                i = self.arrRight.count;
            }
        }
        float h = 0;
        if (iPhone6Plus_6sPlus) {
            h = 298;
        }else if (iPhone6_6s) {
            h = 288;
        }else if (XIPHONE) {
            h = 288;
        }else {
            h = 266;
        }
        self.tableRight.frame = CGRectMake(WSCREENH_WIDTH/2, h - offsetH, WSCREENH_WIDTH/2, 40*i);

        WLog(@"%@",_FGFLArrM);
        WLog(@"%@",_FGFLIDArrM);
        _cid = [_FGFLIDArrM objectAtIndex:indexPath.row];// 取法规分类的id
        _szid = [_FGSZIDArrM objectAtIndex:indexPath.item];// 取法规税种的id
        [self requestListDataStrNum:@"1" isRefresh:YES];
        
        [self.tableRight reloadData];
    } else if (tableView == self.tableRight) {
        WLog(@"%@",_arrRight);
        WLog(@"%@",_FGSZIDArrM);
        WLog(@"%@",_FGFLArrM);
        WLog(@"%@",_FGFLIDArrM);
//        _cid = [_FGFLIDArrM objectAtIndex:indexPath.row];// 取法规分类的id
        _szid = [_FGSZIDArrM objectAtIndex:indexPath.row];// 取法规税种的id
        [self requestListDataStrNum:@"1" isRefresh:YES];
        
        isCate = YES;
        strCate = self.arrRight[indexPath.row];
        [bgView removeFromSuperview];
        [self.tableRight removeFromSuperview];
        [self.tableLeft removeFromSuperview];
        [self.myTableView reloadData];
    } else if (tableView == self.tableDate) {
        isDate = YES;
        strDate = self.RQArrM[indexPath.row];
        [bgView removeFromSuperview];
        [self.tableDate removeFromSuperview];

        WLog(@"%@",self.RQArrM);
        _rq = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
        [self requestListDataStrNum:@"1" isRefresh:YES];

        [self.myTableView reloadData];
    } else {

        [tableView deselectRowAtIndexPath:indexPath animated:NO];

        if (isRegulations) {//众可信法规cell

            if (self.arrMfG.count <= 0) {
                return;
            }
            [self requestDataCid:[self.arrMfG[indexPath.row] strId]];
            
        }else{
            WWebViewController *webVc = [[WWebViewController alloc] init];
            webVc.strTitle = @"税信";
            
            webVc.shareTitle = [self.arrTaxInfo[indexPath.row] strTitle];//分享标题
            webVc.strID = [self.arrTaxInfo[indexPath.row] strId];//分享ID
            webVc.strType = @"sx";//分享类型税信
            
            webVc.strUrl = [self.arrTaxInfo[indexPath.row] link];
            [self.navigationController pushViewController:webVc animated:YES];
        }
    }
}

//分组个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    if (tableView == self.myTableView) {
        return 2;
    }else {
        return 1;
    }
}

//列表行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.tableRight) {
        return self.arrRight.count;
    }else if (tableView == self.tableDate) {
        return self.RQArrM.count;
    }else if (tableView == self.tableLeft) {
        return self.FGFLArrM.count;
    }else {
        if (section == 0) {
            return 1;
        }else{
            
            if (isRegulations) {//众可信法规cell
                WLog(@"行数%ld",self.arrMfG.count);
                return self.arrMfG.count;
            }else{
                return self.arrTaxInfo.count;
            }
        }
    }
}

//设置行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (tableView == self.tableRight) {
        return 40;
    }else if (tableView == self.tableDate) {
        return 40;
    }else if (tableView == self.tableLeft) {
        return 40;
    }else {
        if (indexPath.section == 0) {

            if (iPhone6Plus_6sPlus) {
                return 220;
            }
            return 200;
        }else{
            
            if (isRegulations) {//众可信法规cell
                return cellTitH + 68;

            }else{
                return 70;
            }
        }
    }
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    UIView *view;
    if (section == 1) {

        if (!_taxHeadView) {
            _taxHeadView = [[[NSBundle mainBundle] loadNibNamed:@"TaxInfoHead" owner:self options:nil] lastObject];
            [_taxHeadView.btnNew setTitleColor:[UIColor colorWithRed:0.17 green:0.56 blue:0.99 alpha:1] forState:UIControlStateNormal];
            _taxHeadView.lineNew.hidden = NO;
            _taxHeadView.lineHot.hidden = YES;
            _taxHeadView.lineRegulation.hidden = YES;
        }

        if (isRegulations) {
            _taxHeadView.viewRegulations.hidden = NO;
            if (isDate) {
                _taxHeadView.lbDate.text = strDate;
            }
            if (isCate) {
                _taxHeadView.lbCate.text = strCate;
            }
        } else {
            _taxHeadView.viewRegulations.hidden = YES;
        }
        _taxHeadView.delegate = self;
        return _taxHeadView;
    }
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {

    CGFloat h = 0;
    if (section == 1) {
        if (isRegulations) {
            h = 85;
        } else {
            h = 44;
        }
        return h;
    }
    return h;
}

- (void)delegatHeadBtnClick:(UIButton *)button {

    if (button.tag == 2000) {
        [_taxHeadView.btnNew setTitleColor:[UIColor colorWithRed:0.17 green:0.56 blue:0.99 alpha:1] forState:UIControlStateNormal];
        [_taxHeadView.btnHot setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_taxHeadView.btnRegulation setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _taxHeadView.lineNew.hidden = NO;
        _taxHeadView.lineHot.hidden = YES;
        _taxHeadView.lineRegulation.hidden = YES;
        [self requestListDataStrNum:@"1" sort:@"new" isRefrsh:YES];
        [self notifyRequestListData:@"new"];
        isRegulations = NO;

    } else if (button.tag == 2001) {
        [_taxHeadView.btnNew setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_taxHeadView.btnHot setTitleColor:[UIColor colorWithRed:0.17 green:0.56 blue:0.99 alpha:1] forState:UIControlStateNormal];
        [_taxHeadView.btnRegulation setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _taxHeadView.lineNew.hidden = YES;
        _taxHeadView.lineHot.hidden = NO;
        _taxHeadView.lineRegulation.hidden = YES;
        [self requestListDataStrNum:@"1" sort:@"hot" isRefrsh:YES];
        [self notifyRequestListData:@"hot"];
        isRegulations = NO;
    } else if (button.tag == 2002) {//法规接口
        [_taxHeadView.btnNew setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_taxHeadView.btnHot setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_taxHeadView.btnRegulation setTitleColor:[UIColor colorWithRed:0.17 green:0.56 blue:0.99 alpha:1] forState:UIControlStateNormal];
        _taxHeadView.lineNew.hidden = YES;
        _taxHeadView.lineHot.hidden = YES;
        _taxHeadView.lineRegulation.hidden = NO;
        [self requestListDataStrNum:@"1" isRefresh:YES];
        [self.myTableView reloadData];

        isRegulations = YES;

        if (isRegulations) {
            _taxHeadView.viewRegulations.hidden = NO;
            _taxHeadView.constraintH.constant = 40;
        }else {
            _taxHeadView.viewRegulations.hidden = YES;
            _taxHeadView.constraintH.constant = 0;
        }
    } else if (button.tag == 3000) {
        bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        bgView.backgroundColor = [UIColor colorWithRed:0.16 green:0.17 blue:0.21 alpha:0.3];
        [self.view addSubview:bgView];

        [self.FGSZArrM removeAllObjects];
        [self.FGSZArrM addObject:self.FGSZArrM1];
        for (int i = 0; i < self.FGFLArrM.count - 1; i++) {
            [self.FGSZArrM addObject:@[]];
        }
        [self creatTableView];
    } else if (button.tag == 3001) {
        bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        bgView.backgroundColor = [UIColor colorWithRed:0.16 green:0.17 blue:0.21 alpha:0.3];
        [self.view addSubview:bgView];
        [self creatDateTableView];
    }
}

- (void)delegatBtnClick:(UIButton *)button {

    if (button.tag == 1000) {
        SpokenViewController *spokenVc = [[SpokenViewController alloc] init];
        [self.navigationController pushViewController:spokenVc animated:YES];
    } else if (button.tag == 1001) {
        TaxInfoDetailViewController *taxInfoDetailVc = [[TaxInfoDetailViewController alloc] init];
        [self.navigationController pushViewController:taxInfoDetailVc animated:YES];
    } else if (button.tag == 1002) {
        WWebViewController *webVc = [[WWebViewController alloc] init];
        webVc.strTitle = @"税信月刊";
//        webVc.strUrl = @"http://192.168.0.38:11000/sxhtjs/zstapp?params=%2FO5VEuP53%2BWqeopc9K5F1VM9cHFSt7skYkaNuWT%2BEhOb%2FOA%2FUaQEb%2Bpmqba7brUI";
        webVc.strUrl = _LINK;

        [self.navigationController pushViewController:webVc animated:YES];
    }  else if (button.tag == 3000) {
        bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        [self.view addSubview:bgView];

        [self.FGSZArrM removeAllObjects];
        [self.FGSZArrM addObject:self.FGSZArrM1];
        for (int i = 0; i < self.FGFLArrM.count - 1; i++) {
            [self.FGSZArrM addObject:@[]];
        }
        [self creatTableView];
    } else if (button.tag == 3001) {
        bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        [self.view addSubview:bgView];
        [self creatDateTableView];
    }
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [bgView removeFromSuperview];
    [self.tableDate removeFromSuperview];
    [self.tableLeft removeFromSuperview];
    [self.tableRight removeFromSuperview];
}

#pragma mark - 税信列表的请求
- (void)requestListDataStrNum:(NSString *)pageNum sort:(NSString *)sort isRefrsh:(BOOL)isRefrsh{

    [WShareUtil sharedData].isShowWait = NO;

    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"sxfw",@"content":@{@"revert":@"paginate",@"sort":sort,@"pagesize":@"10",@"pagenumber":pageNum}};

    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};


    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        WLog(@"------%@",responseObject);
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];

        if ([successStr isEqualToString:@"false"]) {
            return;
        }
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];
        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        if (isRefrsh) {
            [self.arrTaxInfo removeAllObjects];
        }

        NSArray *arrData = returnDic[@"data"];

        for (NSDictionary *dic in arrData) {
            TaxInfoModel *taxInfoModel = [TaxInfoModel mj_objectWithKeyValues:dic];
            [self.arrTaxInfo addObject:taxInfoModel];
        }
        [self.myTableView reloadData];
        
        [self noWifiRefershingEnd];

        if (arrData.count < 10) {
            // 拿到当前的上拉刷新控件，变为没有更多数据的状态
            [self.myTableView.footer endRefreshingWithNoMoreData];
        }

    } failure:^(NSError *error) {
        [self noWifiRefershingEnd];
        WLog(@"失败");
    } showProgress:YES];
}

- (void)noWifiRefershingEnd {
    [self.myTableView.header endRefreshing];
    [self.myTableView.footer endRefreshing];
    [WShareUtil sharedData].isShowWait = YES;

}

#pragma mark - 下载法规分类数据
- (void)loadQueryFgFlList {

    if ([WShareUtil strNilOrEmpty:[WShareUtil sharedData].strToken]) {

        HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];
        [loadToken loadToken];

        loadToken.tokenBlock = ^(NSString *strToken) {
            if (![WShareUtil strNilOrEmpty:strToken]) {
                [self loadQueryFgFlList];
            }else {
                WLog(@"没有token");
            }
        };
        WLog(@"%@",[WShareUtil sharedData].strToken);

    }else {
        NSString *uuid= @"e1e1e1";
        NSDictionary *parametersDict = @{@"jqbh":uuid,@"token":[WShareUtil sharedData].strToken,@"password":@"1"};
        // 字典转JSON字符串

        NSString *jsonData = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];

        // 加密JSON字符串
        WLog(@"加密JSON字符串的结果%@",[CommonFunc encryptWithText:jsonData]);//加密方法
        WLog(@"解密乱码后的结果%@",[CommonFunc decryptWithText:@"sZjh+Dfxf1kcn5u4bgq"]);//解密方法

        // 加密后字典参数
        NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:jsonData]};

 
        NSString *url = @"http://mobile.csfw360.com:18082/csfw_jiekou/hangxin/queryFgFlList";
//        NSString *url = @"http://192.168.252.125:8889/csfw_jiekou/article/queryFgFlList";

        [WHttpTool POST:url parameters:paramsDic success:^(id responseObj) {
            NSString *responseStr = [[NSString alloc] initWithData:responseObj encoding:NSUTF8StringEncoding];
            NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
            NSString *messageStr = [JsonDic objectForKey:@"message"];
            NSString *successStr= [JsonDic objectForKey:@"success"];
            // 解密请求回的数据（字典）
            [CommonFunc decryptWithText:messageStr];
            NSString *returnStr = [CommonFunc decryptWithText:messageStr];

            int code = [successStr intValue];
            if (code == 1) { // 成功返回数组

                // json字符串转数组
                NSArray *returnArr = [WHttpTool arrayWithJsonString:returnStr];
                WLog(@"转化的(数组格式的)解密数据%@",returnArr);

                for (int i = 0; i < returnArr.count; i++) {
                    [_FGFLArrM addObject:returnArr[i][@"name"]];
                }

                for (int h = 0; h < returnArr.count; h++) {
                    [_FGFLIDArrM addObject:returnArr[h][@"id"]];
                }

            }else if (code == 0) { // 失败返回字典

                // json字符串转字典
                NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

                if ([returnDic[@"resultCode"] isEqualToString:@"EC0001"] || [returnDic[@"resultCode"] isEqualToString:@"EC0002"] ) {

//                    [WShareUtil showAlert:@"温馨提示" message:@"没有token"];

                    return ;

                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0005"]){

                    [WShareUtil showAlert:@"温馨提示" message:@"您的服务已经到期"];
                    return ;

                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0006"]){

                    [WShareUtil showAlert:@"温馨提示" message:@"您被禁止登录"];
                    return ;

                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0008"]){

                    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您的账号未登录，或账号在其他设备登录！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                    [alertView show];

                    [WShareUtil sharedData].dicSession = nil;
                    return ;
                    WLog(@"没有用户");

                }

            }

        } failure:^(NSError *error) {

            WLog(@"请求失败");
        } showProgress:NO];
    }
}

#pragma mark - 下载法规税种数据
- (void)loadqueryFgSzList {

    if ([WShareUtil strNilOrEmpty:[WShareUtil sharedData].strToken]) {

        HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];
        [loadToken loadToken];

        loadToken.tokenBlock = ^(NSString *strToken) {
            if (![WShareUtil strNilOrEmpty:strToken]) {
                [self loadqueryFgSzList];
            }else {
                WLog(@"没有token");
            }
        };
        WLog(@"%@",[WShareUtil sharedData].strToken);

    }else {

        NSString *uuid= @"e1e1e1";
        NSDictionary *parametersDict = @{@"jqbh":uuid,@"token":[WShareUtil sharedData].strToken,@"password":@"1"};

        // 字典转JSON字符串
        NSString *jsonData = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];

        // 加密JSON字符串
        WLog(@"加密JSON字符串的结果%@",[CommonFunc encryptWithText:jsonData]);//加密方法
        WLog(@"解密乱码后的结果%@",[CommonFunc decryptWithText:@"sZjh+Dfxf1kcn5u4bgq"]);//解密方法

        // 加密后字典参数
        NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:jsonData]};

        NSString *url = @"http://mobile.csfw360.com:18082/csfw_jiekou/hangxin/queryFgSzList";
//        NSString *url = @"http://192.168.252.125:8889/csfw_jiekou/article/queryFgSzList";
        [WHttpTool POST:url parameters:paramsDic success:^(id responseObj) {
            NSString *responseStr = [[NSString alloc] initWithData:responseObj encoding:NSUTF8StringEncoding];
            NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
            NSString *messageStr = [JsonDic objectForKey:@"message"];
            NSString *successStr= [JsonDic objectForKey:@"success"];
            // 解密请求回的数据（字典）
            [CommonFunc decryptWithText:messageStr];
            NSString *returnStr = [CommonFunc decryptWithText:messageStr];

            int code = [successStr intValue];
            if (code == 1) { // 成功返回数组

                // json字符串转数组
                NSArray *returnArr = [WHttpTool arrayWithJsonString:returnStr];
                WLog(@"转化的(数组格式的)解密数据%@",returnArr);

                for (int i = 0; i < returnArr.count; i++) {
                    [_FGSZArrM1 addObject:returnArr[i][@"name"]];
                }
                WLog(@"法规税种数组-%@",_FGSZArrM1);
                for (int h = 0; h < returnArr.count; h++) {
                    [_FGSZIDArrM addObject: returnArr[h][@"id"]];
                }
                WLog(@"法规税种id数组-%@",_FGSZIDArrM);

            }else if (code == 0) { // 失败返回字典

                // json字符串转字典
                NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

                if ([returnDic[@"resultCode"] isEqualToString:@"EC0001"] || [returnDic[@"resultCode"] isEqualToString:@"EC0002"] ) {

//                        [WShareUtil showAlert:@"温馨提示" message:@"没有token"];

                        return ;

                    WLog(@"%@====",[WShareUtil sharedData].strToken);
                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0005"]){

                    [WShareUtil showAlert:@"温馨提示" message:@"您的服务已经到期"];
                    return ;

                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0006"]){

                    [WShareUtil showAlert:@"温馨提示" message:@"您被禁止登录"];
                    return ;

                }else if([returnDic[@"resultCode"] isEqualToString:@"EC0008"]){

                    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您的账号未登录，或账号在其他设备登录！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                    [alertView show];

                    [WShareUtil sharedData].dicSession = nil;
                    return ;
                    WLog(@"没有用户");

                }
            }

        } failure:^(NSError *error) {

            WLog(@"请求失败");
        } showProgress:NO];
    }
}


#pragma mark - 下载法规总列表数据
- (void)requestListDataStrNum:(NSString *)pageNum isRefresh:(BOOL)isRefresh{
    if ([WShareUtil strNilOrEmpty:[WShareUtil sharedData].strToken]) {
        HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];// 获取Token （目前先：token过期后，获取一次就关掉）
        [loadToken loadToken];
        loadToken.tokenBlock = ^(NSString *strToken) {
            if (![WShareUtil strNilOrEmpty:strToken]) {
                [self requestListDataStrNum:pageNum isRefresh:isRefresh];
            }else {
                WLog(@"没有token");
            }
        };
        WLog(@"%@",[WShareUtil sharedData].strToken);
    }else {
        
        NSDictionary *parametersDict = @{@"pageNum":pageNum,@"pageSize":@"10",@"cid":_cid,@"szid":_szid,@"rq":_rq};
        // 字典转JSON字符串
        NSString *jsonData = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
        
        // 加密JSON字符串
        WLog(@"加密JSON字符串的结果%@",[CommonFunc encryptWithText:jsonData]);//加密方法
        WLog(@"解密乱码后的结果%@",[CommonFunc decryptWithText:@"sZjh+Dfxf1kcn5u4bgq4g75bHbBQ6DlL2oF3ELtxXb8dkwb1w5GRyfm7huCriDvlsdsFDoOWLqzX7tt+NpCuiEApxy+2QONMEZpGLBejk+1ZPreDtd3O7Q=="]);//解密方法
        
        // 加密后字典参数
        NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:jsonData]};
        
        NSString *url = @"http://mobile.csfw360.com:18082/csfw_jiekou/hangxin/fgList";
        
        [WHttpTool POST:url parameters:paramsDic success:^(id responseObject) {
            NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
            NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
            
            NSString *messageStr = [JsonDic objectForKey:@"message"];
            NSString *successStr= [JsonDic objectForKey:@"success"];
            // 解密请求回的数据（字典）
            [CommonFunc decryptWithText:messageStr];
            NSString *returnStr = [CommonFunc decryptWithText:messageStr];
            // json字符串转字典
            NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];
            
            if ([returnDic[@"resultCode"] isEqualToString:@"EC0001"] || [returnDic[@"resultCode"] isEqualToString:@"EC0002"] ) {
                HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];// 获取Token （目前先：token过期后，获取一次就关掉）
                [loadToken loadToken];
                loadToken.tokenBlock = ^(NSString *strToken) {
                    if (![WShareUtil strNilOrEmpty:strToken]) {
                        [self requestListDataStrNum:pageNum isRefresh:isRefresh];
                    }else {
                        
                        [WShareUtil showAlert:@"温馨提示" message:@"没有token"];
                        
                        return ;
                        
                        WLog(@"没有token");
                    }
                };
                
                WLog(@"%@====",[WShareUtil sharedData].strToken);
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0005"]){
                
                [WShareUtil showAlert:@"温馨提示" message:@"您的服务已经到期"];
                return ;
                
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0006"]){
                
                [WShareUtil showAlert:@"温馨提示" message:@"您被禁止登录"];
                return ;
                
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0008"]){
                
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您的账号可能在其他设备登录,是否要重新登录？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"重新登录", nil];
                [alertView show];
                
                [WShareUtil sharedData].dicSession = nil;
                return ;
                WLog(@"没有用户");
                
            }
            
            if (isRefresh) {
                [self.arrMfG removeAllObjects];
            }
            
            for (NSDictionary *dic in returnDic[@"data"]) {
                FGModel *fGmodel = [FGModel mj_objectWithKeyValues:dic];
                [self.arrMfG addObject:fGmodel];
            }
            [WShareUtil removeModelDataWithFile:@"RegulationList"];
            [WShareUtil saveModelData:self.arrMfG WithFile:@"RegulationList"];
            [[self myTableView] reloadData];

            [self.myTableView.header endRefreshing];
            [self.myTableView.footer endRefreshing];
            
            //            ///* --- 图片式提醒
            //            UIView *view = [self.myTableView viewWithTag:10000];
            //            [view removeFromSuperview];
            //            HHNonePage *_nonePage = [[HHNonePage alloc]init];
            //            _nonePage = nil;
            //            if (_arrMfG.count == 0) {
            //                _nonePage = [[HHNonePage alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
            //                _nonePage.tag = 10000;
            //                [_myTableView addSubview:_nonePage];
            //            }
            //            //*/
            
            if ([returnDic[@"data"] count] < 10) {
                // 拿到当前的上拉刷新控件，变为没有更多数据的状态
                [self.myTableView.footer endRefreshingWithNoMoreData];
            }
            
        } failure:^(NSError *error) {
            [self noWifiRefershingEnd];
            WLog(@"请求失败");
        } showProgress:YES];
    }
}


#pragma mark - 下载文章详情数据
- (void)requestDataCid:(NSString *)cid {
    
    if ([WShareUtil strNilOrEmpty:[WShareUtil sharedData].strToken]) {
        HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];// 获取Token （目前先：tokesn过期后，获取一次就关掉）
        [loadToken loadToken];
        loadToken.tokenBlock = ^(NSString *strToken) {
            if (![WShareUtil strNilOrEmpty:strToken]) {
                [self requestDataCid:cid];
            }else {
                WLog(@"没有token");
            }
        };
        WLog(@"%@",[WShareUtil sharedData].strToken);
    }else {
        
        NSString *userId;
        if ([WShareUtil sharedData].dicSession) {
            userId = @"141978";
            if (userId == nil) {
                userId = @"-1";
            }
            
        }else {
            userId = @"-1";
        }
        NSString *uuid= @"e1e1e1";
        NSDictionary *parametersDict = @{@"jqbh":uuid,@"token":[WShareUtil sharedData].strToken,@"id":cid,@"userid":userId};
        // 字典转JSON字符串
        NSString *jsonData = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
        
        // 加密JSON字符串
        WLog(@"加密JSON字符串的结果%@",[CommonFunc encryptWithText:jsonData]);//加密方法
        WLog(@"解密乱码后的结果%@",[CommonFunc decryptWithText:@"sZjh+Dfxf1kcn5u4bgq4g75bHbBQ6DlL2oF3ELtxXb8dkwb1w5GRyfm7huCriDvlsdsFDoOWLqzX7tt+NpCuiEApxy+2QONMEZpGLBejk+1ZPreDtd3O7Q=="]);//解密方法
        
        // 加密后字典参数
        NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:jsonData]};
        
        NSString *url = @"http://mobile.csfw360.com:18082/csfw_jiekou/hangxin/articleIndex";
        [WHttpTool POST:url parameters:paramsDic success:^(id responseObject) {
            
            NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
            NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        
            NSString *messageStr = [JsonDic objectForKey:@"message"];
            NSString *successStr= [JsonDic objectForKey:@"success"];
            // 解密请求回的数据（字典）
            [CommonFunc decryptWithText:messageStr];
            NSString *returnStr = [CommonFunc decryptWithText:messageStr];
            // json字符串转字典
            NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];
            
            if ([returnDic[@"resultCode"] isEqualToString:@"EC0001"] || [returnDic[@"resultCode"] isEqualToString:@"EC0002"] ) {
                HHBaseLoadToken *loadToken = [[HHBaseLoadToken alloc] init];// 获取Token （目前先：token过期后，获取一次就关掉）
                [loadToken loadToken];
                loadToken.tokenBlock = ^(NSString *strToken) {
                    if (![WShareUtil strNilOrEmpty:strToken]) {
                        [self requestDataCid:cid];
                    }else {
                        
                        [WShareUtil showAlert:@"温馨提示" message:@"没有token"];
                        
                        return ;
                        
                        WLog(@"没有token");
                    }
                };
                
                WLog(@"%@====",[WShareUtil sharedData].strToken);
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0005"]){
                
                [WShareUtil showAlert:@"温馨提示" message:@"您的服务已经到期"];
                return ;
                
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0006"]){
                
                [WShareUtil showAlert:@"温馨提示" message:@"您被禁止登录"];
                return ;
                
            }else if([returnDic[@"resultCode"] isEqualToString:@"EC0008"]){
                
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您的账号可能在其他设备登录,是否要重新登录？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"重新登录", nil];
                [alertView show];
                
                [WShareUtil sharedData].dicSession = nil;
                return ;
                WLog(@"没有用户");
                
            }
            
            NSNumber *gid;
            if ([WShareUtil sharedData].dicSession) {
                gid = [WShareUtil getDataWithUserDefaultsForKey:GIDVALUE];
            } else {
                gid = [WShareUtil getDataWithUserDefaultsForKey:YKGIDVALUE];
            }
            NSNumber *rank = returnDic[@"rank"];
            
            WLog(@"%@gid",gid);
            WLog(@"%@rank",rank);
            
            if (gid.intValue == 1 && rank.intValue != 0) {
                [SVProgressHUD showImage:nil status:@"用户权限不够，去我的页面购买后才能查看"];
                [SVProgressHUD setOffsetFromCenter:UIOffsetMake(0, WSCREENH_HEIGHT *0.5 - 70)];
                [SVProgressHUD dismissWithDelay:1.];
                [SVProgressHUD setBackgroundColor:[UIColor colorWithRed:0.9 green:0.91 blue:0.93 alpha:1]];
                return;
            }
            
            if (gid.intValue < rank.intValue) {
                [SVProgressHUD showImage:nil status:@"用户权限不够，去我的页面购买后才能查看"];
                [SVProgressHUD setOffsetFromCenter:UIOffsetMake(0, WSCREENH_HEIGHT *0.5 - 70)];
                [SVProgressHUD dismissWithDelay:1.];
                [SVProgressHUD setBackgroundColor:[UIColor colorWithRed:0.9 green:0.91 blue:0.93 alpha:1]];
                return;
            }
            
            TextDetailViewController *textDetailVC = [[TextDetailViewController alloc]init];
            //跳转时隐藏标签栏
            textDetailVC.hidesBottomBarWhenPushed=YES;
            textDetailVC.dicData = returnDic;
            [self.navigationController pushViewController:textDetailVC animated:YES];
            
        } failure:^(NSError *error) {
            WLog(@"请求失败");
            
        } showProgress:YES];
        
    }
}

-(void)creatDateTableView{
    float h = 0;
    if (iPhone6Plus_6sPlus) {
        h = 298;
    }else if (iPhone6_6s) {
        h = 288;
    }else if (XIPHONE) {
        h = 288;
    }else {
        h = 266;
    }
    self.tableDate = [[UITableView alloc]initWithFrame:CGRectMake(0, h - offsetH, WSCREENH_WIDTH, 40*self.RQArrM.count) style:UITableViewStylePlain];
    self.tableDate.delegate = self;
    self.tableDate.dataSource = self;
    [self.view addSubview:self.tableDate];
}

-(void)creatTableView{
    float h = 0;
    if (iPhone6Plus_6sPlus) {
        h = 298;
    }else if (iPhone6_6s) {
        h = 288;
    }else if (XIPHONE) {
        h = 288;
    }else {
        h = 266;
    }

    self.tableLeft = [[UITableView alloc]initWithFrame:CGRectMake(0, h - offsetH, WSCREENH_WIDTH/2, 40*self.FGFLArrM.count) style:UITableViewStylePlain];
    self.tableLeft.delegate = self;
    self.tableLeft.dataSource = self;
    [self.view addSubview:self.tableLeft];

    self.arrRight = self.FGSZArrM[0];
    NSInteger i = 0;
    if (self.arrRight.count > 6) {
        i = 6;
    }else {
        i = self.arrRight.count;
    }
//    WLog(@"%@",self.arrRight);
    self.tableRight = [[UITableView alloc]initWithFrame:CGRectMake(WSCREENH_WIDTH/2, h - offsetH, WSCREENH_WIDTH/2, 40*i) style:UITableViewStylePlain];
    self.tableRight.delegate = self;
    self.tableRight.dataSource = self;
    [self.view addSubview:self.tableRight];
    self.tableRight.hidden = YES;
}

// 解读按钮实现的方法
- (void)jiedu:(UIButton *)button {
    
    [self requestDataCid:[self.arrMfG[button.tag] jdid]];

}

@end
